package cate.game.play.skill.passive.god;

import cate.common.util.XT;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

import java.util.List;

/**
 * 攻击时40%概率附加【绝对零度】；受击2次后解除，解除时受到施法者攻击力40%的伤害，至多2目标
 */
public class 沙暴送葬PH extends PassiveHandler {

	private int 概率;

	private List<Integer> buff;

	private int 人数;

	//概率=4000&buff=??#??&人数=2
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		buff = args.getIntList("buff");
		人数 = args.getInt("人数", 0);
	}

	@Override
	public void onSkillDone(SkillActionCtx action) {
		if (XT.isBlank(action.getTargets())) {
			return;
		}
		if (!action.getSkill().cfg.isHurtSkill()) {
			return;
		}
		int addNum = 0;
		for (Fighter target : action.getTargets()) {
			if (!XT.chance(概率)) {
				continue;
			}
			for (Integer addBuff : buff) {
				target.buff.tryAddByTid(action, skill.owner, addBuff);
			}
			addNum++;
			if (addNum >= 人数) {
				return;
			}
		}
	}
}
